using System;
using UnityEngine;

public class DoodlePreferences
{
	public const long DAY = 864000000000L;

	private static bool initiliazed;

	public static bool isFirstOpen;

	private static long timeOnSale;

	private static int OnSaleBuyCount;

	public static long GetTimeOnSaleLeft()
	{
		return (timeOnSale - DateTime.Now.Ticks) / 10000000;
	}

	public static void init()
	{
		if (!initiliazed)
		{
			initiliazed = true;
			isFirstOpen = (PlayerPrefs.GetInt("firstOpen", 1) == 1);
			if (isFirstOpen)
			{
				timeOnSale = DateTime.Now.Ticks + 1728000000000L;
				PlayerPrefs.SetString("timeOnSale", timeOnSale.ToString());
				PlayerPrefs.SetInt("firstOpen", 0);
			}
			else
			{
				try
				{
					timeOnSale = long.Parse(PlayerPrefs.GetString("timeOnSale"));
				}
				catch (Exception ex)
				{
					UnityEngine.Debug.Log(ex.StackTrace);
					timeOnSale = DateTime.Now.Ticks + 1728000000000L;
					PlayerPrefs.SetString("timeOnSale", timeOnSale.ToString());
				}
			}
			OnSaleBuyCount = PlayerPrefs.GetInt("OnSaleBuyCount", 0);
		}
	}

	public static int GetOnSaleBuyCount()
	{
		if (!initiliazed)
		{
			init();
		}
		return OnSaleBuyCount;
	}

	public static void SetOnSaleBuyCount(int count)
	{
		if (!initiliazed)
		{
			init();
		}
		OnSaleBuyCount = count;
		PlayerPrefs.SetInt("OnSaleBuyCount", OnSaleBuyCount);
	}
}
